package com.study.project.config.exception;

import java.text.MessageFormat;
import java.util.List;

/**
 * @author chenHao
 * @date 2022/1/25 业务异常枚举
 */
public enum BizErrorCode implements ErrorCode {

    /**
     * 系统错误
     */
    SYSTEM_DEFAULT_ERROR("301010001", "系统错误!"),

    TIME_PARSE_ERR("301010002", "时间[{0}]解析格式[{1}]错误!"),

    SYSTEM_BUSY_ERROR("301010003", "系统繁忙稍后再试!"), CHECK_PARAM_ERROR("301010004", "参数校验不通过!"),
    SYSTEM_NET_ERROR("301010005", "网络不稳定，请稍后再试!"),

    /**
     * 营销活动类型异常
     */
    MARKETING_ACTIVITY_TYPE_ERROR("301020001", "请选择正确的营销活动类型"),

    /*===============================营销规则异常====================================*/
    /**
     * 营销活动规则解析异常
     */
    MARKETING_ACTIVITY_RULE_ERROR("301030001", "营销活动规则输入有误"),
    /**
     * 营销活动规则json非法
     */
    MARKETING_ACTIVITY_RULE_JSON_ILLEGAL("301030001", "营销活动规则json非法"),

    /**
     * 营销活动规则json非法
     */
    MARKETING_ACTIVITY_GIFT_CONF_RULE_JSON_ILLEGAL("301030001", "营销活动礼品配置规则json非法"),

    /**
     * 营销活动礼品规则解析异常
     */
    MARKETING_ACTIVITY_GIFT_RULE_ERROR("301030002", "营销活动礼品规则输入有误"),

    MARKETING_ACTIVITY_NOT_APPLY_MULTI_RULE("301030003", "当前活动不支持多规则"),

    MARKETING_ACTIVITY_AWARD_DISTRIBUTE_TIME_ERROR("301030004", "时间点请选择0 - 23点"),

    MARKETING_ACTIVITY_AWARD_DELAYDAYS_ERROR("301030005", "请输入开卡后延迟发放的天数"),

    MARKETING_ACTIVITY_AWARD_PERIOD_TYPE_ERROR("301030006", "周期发放时请选择每天、每周或每月"),

    MARKETING_ACTIVITY_AWARD_PERIOD_WEEK_ERROR("301030007", "周期为每周时请选择周一 - 周日"),

    MARKETING_ACTIVITY_AWARD_PERIOD_MONTH_ERROR("301030008", "周期为每月时请选择1号 - 31号"),

    MARKETING_ACTIVITY_CHARGE_COUPON_JOINPERIOD_ERROR("301030009", "周期类型下的参与周期不能为空"),

    MARKETING_ACTIVITY_CHARGE_COUPON_LIMITJOINTIMES_ERROR("3010300010", "参与活动限制次数不能为空"),

    MARKETING_ACTIVITY_BIRTHDAY_MEMBER_SCOPE_ERROR("3010300011", "会员范围请选择卡等级或会员标签"),
    MARKETING_ACTIVITY_BIRTHDAY_MEMBER_SCOPE_CHOOSE_EMPTY_ERROR("3010300012", "会员范围下请进行选择内容"),

    MARKETING_ACTIVITY_BIRTHDAY_MEMBER_SCOPE_MULTIRULE_CHOOSE_EMPTY_ERROR("3010300013", "会员范围下第{0}条规则请进行选择内容"),

    MARKETING_ACTIVITY_BIRTHDAY_MEMBER_SCOPE_MULTIRULE_CHOSEN_ERROR("3010300014", "会员范围下第{0}条规则下选择的内容有误"),

    /*===============================营销活动状态异常====================================*/

    /**
     * 营销活动不存在
     */
    MARKETING_ACTIVITY_NOT_EXIST("301040001", "活动ID{0}不存在"),

    /**
     * 营销活动已被删除
     */
    MARKETING_ACTIVITY_DELETED("301040002", "营销活动[{0}]已被删除"),

    /**
     * 营销活动已被删除
     */
    MARKETING_ACTIVITY_HAVE_ENABLED("301040002", "当前活动已是启用状态"),

    /**
     * 营销活动不是启用状态
     */
    MARKETING_ACTIVITY_NOT_ENABLED("301040003", "活动暂时无法参与"),
    /**
     * 营销活动同一时间已存在
     */
    MARKETING_ACTIVITY_HAVE_SAVE_TIME("301040006", "当前活动类型同一时间已有启用"),

    /**
     * 营销活动启用的时候有相同类型活动也在启用导致冲突 0.品牌名称、店铺名称、 卡方案名称、卡等级名称 1.活动名称
     */
    MARKETING_ACTIVITY_ENABLE_SHOP_CLASH("301040004", "启用失败，{0} 已存在 【{1}】。"),

    /**
     * 营销活动启用的时候有相同类型活动也在启用导致冲突 0.卡方案名称 1.品牌名称、店铺名称 2.活动名称
     */
    MARKETING_ACTIVITY_ENABLE_CARD_CLASH("301040005", "启用失败，【{0}】 ,{1}已存在 【{2}】。"),

    /*===============================营销活动业务异常====================================*/

    MARKETING_ACTIVITY_JOIN_FREQUENT("301040002", "参与活动过于频繁"),

    MARKETING_ACTIVITY_GIFT_NO_STOCK("301040003", "很可惜～活动[{0}]礼品已经送完"),

    MARKETING_ACTIVITY_PERSONAL_JOIN_TIMES_LIMIT("301040004", "已超过个人参与最大活动次数"),

    MARKETING_ACTIVITY_BUSINESS_SCENE_NOT_SUPPORT("301040005", "当前活动不适用于当前业务场景"),

    MARKETING_ACTIVITY_JOIN_MEMBER_MAX_LIMIT("301040006", "已超过参与活动最大人数"),

    EMPTY_PAYMENT_LINK_BILL_NO("301040007", "订单号不能为空"),

    MARKETING_ACTIVITY_RECEIVE_GIFT_LIMIT("301040008", "已超过最大礼品领取次数"),

    MARKETING_ACTIVITY_TYPE_NULL("301040009", "营销活动类型不能为空"),

    MARKETING_ACTIVITY_NOT_START("301040010", "活动未开始"),

    MARKETING_ACTIVITY_HAS_END("301040011", "活动已经结束"),

    MARKETING_SHARE_ACTIVITY_HAS_JOINED("301040012", "已经参与过当前分享活动"),

    REPEAT_SIGN_IN("301040013", "您今日已签到了"),

    RED_ENVELOPE_NOT_LEFT("301040014", "红包已被抢完了"),

    INSUFFICIENT_POINTS("301040015", "积分不足"),

    MARKETING_ACTIVITY_NO_AVAILABLE_STORES("301040016", "当前营销活动无可用店铺"),

    MARKETING_ACTIVITY_SHOP_NOT_SUPPORT("301040017", "当前活动不适用于当前店铺"),

    MARKETING_ACTIVITY_APPLY_CHANNEL_TYPE_SUPPORT("301040018", "当前活动不适用于当前消费渠道"),

    EVALUATE_EXPIRED("301040019", "当前评价已过期，无法参与评价有礼活动"),

    UNSATISFIED_ACTIVITY_TRIGGER_CONDITION("301040020", "未满足活动礼品触发条件"),

    MARKETING_ACTIVITY_HAVE_NOT_GIFT_CONF("301040021", "当前活动{0}没有活动礼品配置"),

    INSUFFICIENT_DOT_CARD("301040022", "集点卡点数不足"),

    SHARE_EVENT_NOT_EXIST("301040023", "分享活动不存在"),

    JOIN_ACTIVITY_NUMBER_TYPE_ERROR("301040024", "参与活动限制次数类型错误"),

    PASSWORD_ERROR("301040025", "口令错误～请尝试其他口令"),

    COUPON_BATCH_NOT_GENERATED("301040026", "券批次未生成，请重新配置营销内容"),

    PASSWORD_USE_TIMES_LIMIT_ERROR("301040027", "该口令奖励已全部被领完～"),

    FREE_COUPON_COLLECTION_NO_AVAILABLE_CURRENT_REGION("301040028", "当前地区不可享用免费领券活动"),

    INTEGRAL_DEDUCTION_FAILED("301040029", "积分扣除失败"),

    MARKETING_SHARE_ACTIVITY_EXISTS("301040030", "当前用户已经存在分享活动"),

    BRAND_NOT_SUIT_ERROR("301040031", "当前品牌不适用此活动"),

    INSUFFICIENT_CONSUMPTION_AMOUNT("301040032", "消费金额满足参加活动金额"),

    SCENE_MISMATCH("301040033", "消费场景不匹配"),

    APPLICAVLE_CHANNELS("301040034", "适用渠道不匹配"),

    MENBER_RANGE("301040035", "您当前还不符合购买条件，请仔细阅读活动规则哦～"),

    INSUFFICIENT_AMOUNT("301040036", "消费金额不足"),

    MARKETING_SHARE_ACTIVITY_NOT_JOINED("301040037", "没有参与过当前分享活动"),

    GOODS_SCOPE("301040038", "商品不匹配"),

    INSUFFICIENT_GOODS_STOCK("301040039", "库存不足"),

    ORDER_PAY_DATA_NOT_FOUND("301040040", "暂无订单支付数据"),

    MARKETING_ACTIVITY_CAN_NOT_USE("301040041", "活动暂不可用"),

    ENTITY_BATCH_NOT_GENERATED("301040042", "实物礼品批次未生成，请重新配置营销内容"),

    GIFT_RECEIVE_FREQUENT("301040043", "领取过于频繁"),

    COLLECT_DOT_NO_ACHIEVE_TARGET("301040044", "集点未满足兑换要求,请刷新页面再试"),

    ACTIVITY_NO_GIFT_CONF("301040045", "活动没有礼物配置"),

    ACTIVITY_NO_VALID("301040046", "无效活动"),

    FREE_COUPON_COLLECTION_NO_AVAILABLE("301040047", "当前未开放领取，请前往活动规则了解详情"),

    FREE_COUPON_COLLECTION_NOT_RANGE("301040048", "很抱歉～暂不满足领取条件"),

    GIFT_HAS_RECEIVE("301040049", "当前礼品已经领取"),

    NOT_JOIN_MY_ACTIVITY("301040050", "不能参与自己分享的活动哦"),

    CANT_JOIN_RECOMMEND_ACTIVITY("301040051", "不满足参与活动的条件哦"),

    RECOMMEND_ACTIVITY_MEMBER_SEARCH_ERROR("301040052", "查询新注册会员的信息异常哦"),

    RECOMMEND_ACTIVITY_NON_CONSUMED_GIFT("301040053", "推荐有礼活动无消费后可领取的礼品"),

    JOIN_MUST_BE_NEW_MEMBER("301040054", "该活动仅限新用户参与哦~"),

    FREE_COUPON_ICC_ASSOCIATION_NOT_UNIONID("301040055", "很抱歉～请传入unionId呢"),

    FREE_COUPON_ICC_GROUP_NOT_JOIN("301040056", "请加入宠粉群后再领取～"),

    FREE_COUPON_ICC_PERSONAL_NOT_JOIN("301040057", "请添加丁丁猫好友再领取～"),

    ACTIVITY_NO_STOCK("301040049", "当前商品商品无库存,暂时无法加入拼团"),

    PURCHASE_STATE("301040050", "只有进行中的团才可以加入"),

    PURCHASE_FULL("301040051", "该拼团已满员～无法加入"),

    SIGNIN_ACTIVITY_GIFT_NO_STOCK("301040052", "{0}活动[{1}]的签到{2}礼品已经送完"),

    MARKETING_ACTIVITY_ENDTIME_IS_BEFORE_CURRENTTIME("301040058", "【{0}】活动结束时间不能早于当前时间"),

    MARKETING_ACTIVITY_ENDTIME_IS_BEFORE_STARTTIME("301040059", "【{0}】活动结束时间不能早于开始时间"),

    MARKETING_ACTIVITY_STARTTIME_ENDTIME_ERROR("301040060", "【{0}】活动开始与结束时间需满足yyyyMMddHHmmss"),

    /*===============================rpc Client 异常====================================*/

    COUPON_RPC_SAVE_COUPON_ERROR("401040001", "券服务保存券异常"),

    COUPON_ROC_SEND_MEMBER_ERROR("401040002", "发放券/券包异常"),

    MEMBER_TAG_SERVICE_ERROR("401040003", "会员标签服务异常"),

    TASK_SERVICE_ERROR("401040004", "任务中心服务异常"),

    BASIC_SERVICE_ERROR("401040005", "获取商品信息异常"),

    EXPORT_UN_SUPPORT_TYPE("401040006", "不支持的导出类型"),

    EXPORT_QUERY_EXPORT_COUNT_ERROR("401040007", "查询当日导出次数失败"),

    EXPORT_ADD_EXPORT_RECORD_ERROR("401040008", "保存导出记录失败"),

    EXPORT_QUERY_EXPORT_RECORD_ERROR("401040009", "查询导出记录失败"),

    EXPORT_UPDATE_EXPORT_RECORD_ERROR("401040010", "更新导出记录失败"),

    EXPORT_NO_DATA("401040011", "无需要导出的数据"),

    EXPORT_OUT_BATCH_SIZE_LIMIT("401040012", "导出数据量超出限制"),

    COUPON_RPC_SAVE_QUERY_ERROR("401040013", "券服务查询异常"),

    ICC_HTTP_INVOKE_ERROR("401040014", "icc服务查询用户社群状态异常"),

    /*==========================缺少参数=====================*/
    MEMBER_ID("501040001", "会员id不能为空"), BRAND_ID("501140001", "品牌id不能为空"),
    CHARGE_GROUP_PURCHASE_STOCK("301030101", "修改库存不得小于原有库存"),

    COLLECT_DOT_ERROR("501040010", "集点卡门店校验错误"), CARD_LEVEL_BRAND_ERROR("501040011", "该品牌下的卡等级数据转换异常,未获取到正确卡等级id"),
    CARD_LEVEL_ERROR("501040012", "调用会员卡等级查询服务错误，需要会员服务排查"), BILL_QUERY_ERROR("501040013", "年度账单服务查询异常,请稍后重试!"),
    PRIZE_QUERY_ERROR("501040014", "服务查询异常,请稍后重试!"), INSUFFICIENT_FREQUENCY("501040015", "摇奖活动可用次数不足"),
    MARKETING_ACTIVITY_JOIN_NOT_EXIST("501040016", "参与活动记录查询不存在,请传入正确的入参"),
    MARKETING_ACTIVITY_GIFTCONF_NOT_EXIST("501040017", "活动礼品配置查询不存在,请传入正确的入参"),
    MARKETING_ACTIVITY_INVALID_JOIN("501040018", "活动火爆,请稍后再试。。。"),
    JOIN_MUST_BE_OLD_MEMBER("501040019", "该活动仅限于特定老会员参与"), CACHE_GOODS_STOCK_ERROR("501040020", "集点卡库存查询缓存为空"),
    COLLECT_DOT_MEMBER_ERROR("501040021", "集点卡规则下的会员范围配置错误，卡等级查询数据为空"),
    ACTIVITY_MEMBER_CONF_ERROR("501140021", "规则下的会员卡等级配置错误，请仔细检查"), ACTIVITY_NO_GIFT_STOCK("501040020", "活动礼品已经发完"),
    ACTIVITY_NO_GIFT_CONF_DB("501040021", "活动礼品配置匹配错误"),

    ACTIVITY_CODE_IS_NULL("501040025", "活动码不能为空"),
    MARKETING_ACTIVITY_ENABLE_GENERIC_CLASH("501040026", "启用失败，与【{0}】冲突"),
    MARKETING_ORDER_HAS_BEEN_HANDLED("501040027", "订单消费已经被同类活动处理过"), MARKETING_BUSINESS_ERROR("501040028", "查不到活动id"),
    MARKETING_ID_ERROR("501040029", "activityId和businessId不能同时为空"), CLIENT_SYSTEM_ERROR("50022", "网络开小差，请稍候再试～"),
    GIFT_CARD_LEVEL_CONF_NOT_ALL_CONTAIN("501040030", "礼物卡等级配置未全不包含卡等级设置"),
    RECOMMEND_MUST_HAS_GIFT_CONSUME_CONFIG("501040031", "推荐有礼需要配置邀请人奖励类型"),
    SIGN_MUST_HAVE_GIFT_PARAM("501040032", "签到礼品参数必填"), CARD_LEVEL_CONF_IS_WRONG("501040033", "卡等级参数配置错误"),
    ACTIVITY_RESTRICTION_ILLEGAL("501040034", "活动约束类型非法"), APPLY_CHANNEL_TYPE_ILLEGAL("501040035", "渠道范围类型非法"),
    GUARANTEE_TYPE_ILLEGAL("501040036", "保底类型非法"), GIFT_GET_RULE_ERROR("501040037", "礼物获取规则类型非法"),
    ACTIVITY_NO_START("501040129", "活动未开始"), ACTIVITY_END("501040130", "活动已结束"), SHOP_IS_NULL("501040038", "店铺配置信息为空");

    private final String code;

    private final String msg;

    BizErrorCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    public String formatMsg(Object... args) {
        return MessageFormat.format(this.msg, args);
    }
}
